package com.food.user.consumer;

import com.food.user.commos.GlobleStaticNum;
import com.food.user.entity.OrderLog;
import com.food.user.service.OrderLogService;
import com.food.user.util.DateUtils;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;

@Component
@RocketMQMessageListener(consumerGroup = "acceptOrderLog",topic = "merchant_accept_order_log")
public class MerchantAcceptOrderConsumer implements RocketMQListener<String> {
    @Autowired
    private OrderLogService orderLogService;


    @Override
    @Transactional
    public void onMessage(String s) {

        OrderLog orderLog = new OrderLog();
        orderLog.setOrderLogOrderNum(s);
        orderLog.setOrderLogOrderStateId(1);
        orderLog.setOrderLogOrderState("商家接单");
        orderLog.setOrderLogOperContent("商家接单");
        orderLog.setOrderLogOperName("系统自动记录日志");
        orderLog.setOrderLogOperUser("商家");
        orderLog.setOrderLogOperDate(DateUtils.parseString(LocalDateTime.now(),"yyyy-MM-dd HH:mm:ss"));
        orderLogService.save(orderLog);
    }
}
